# Maintainer: Tom Gundersen <teg@jklm.no>
pkgname=hwids
pkgver=20210613
pkgrel=1
pkgdesc="hardware identification databases"
makedepends=('git' 'unoconv')
url=https://github.com/gentoo/hwids
license=('GPL2')
arch=('any')
source=("git+https://github.com/gentoo/hwids.git#tag=${pkgname}-${pkgver}?signed"
	https://download.microsoft.com/download/7/E/7/7E7662CF-CBEA-470B-A97E-CE7CE0D98DC2/ISA_PNPID_List.xlsx)
validpgpkeys=('226DE4AA4B9704A49DEF6B9B1A333AEFBD714C02') # Mike Gilbert
sha256sums=('SKIP'
            '775323da066e5435978eac8e8dd54af15278329d1455e145d163aede27d7998e')
prepare() {
  # from https://github.com/vcrhonek/hwdata/blob/master/Makefile
  unoconv --stdout -f csv ${srcdir}/ISA_PNPID_List.xlsx | \
	    tr ' ' ' ' | \
	    sed -n \
		-e 's/^\s*"\s*\(.*\)\s*"/\1/' \
		-e 's/\s\{2,\}/ /g' \
		-e 's/\s*(used as 2nd pnpid)\s*//' \
		-e 's:^\(.*\)\s*,\s*\([a-zA-Z@]\{3\}\)\s*,\s*\([0-9]\+/[0-9]\+/[0-9]\+\):\2\t\1:p' | \
	    sed 's/\s*$$//' | sort -u >${srcdir}/pnp.ids
}

package() {
  cd hwids

  for ids in pci.ids usb.ids; do
    install -Dm644 "$ids" "${pkgdir}/usr/share/hwdata/${ids}"
  done
  install -Dm644 "${srcdir}/pnp.ids" ${pkgdir}/usr/share/hwdata/pnp.ids 
}
